<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="../back-common.jsp"%>
<%@ include file="/WEB-INF/pages/common/taglib.jsp"%>
         <script type='text/javascript' src="<ls:templateResource item='/resources/common/js/jquery.validate.js'/>" /></script>
         <link rel="stylesheet" type="text/css" media="screen" href="${contextPath}/resources/common/css/errorform.css" />
        <script language="javascript">
		    $.validator.setDefaults({
		    });
    $(document).ready(function() {
    jQuery("#form1").validate({
			rules: {
			groupby: "required",
			province: "required",
			 provinceid: {
             number:true,
             required:true
            }
		},
    messages: {
    		groupby:"请输入区域",
			province:"请输入省份",
			provinceid: {
                number:"请输入正确的邮编，必须是数字",
                required:"请输入邮编"
            }		
		},
	submitHandler:function(form){
	     $.ajax({
	    		url:"${contextPath}/admin/system/district/queryProviceId", 
	    		type:'post', 
	    		data:{"provinceId":$("#provinceid").val(),"id":$("#id").val()},
	    		async : true, //默认为true 异步   
	    		error: function(jqXHR, textStatus, errorThrown) {
	    			 //alert("系统异常" + " jqXHR= " + jqXHR + ", textStatus = " + textStatus + ",errorThrown =  " + errorThrown);
	    		},
	    		success:function(result){
	    		    var _data=eval(result);
	    			if(_data=="fail"){
	    			    art.dialog.tips("该邮编已存在！");
	    			    return false;
	    			}else{
	    			    form.submit();
	    			}
	    		}
	    	});
    }
    });
    
});

</script>
        <form:form  action="${contextPath}/admin/system/district/save" method="post" id="form1">
            <input id="id" name="id" value="${province.id}" type="hidden">
            <div align="center">
            <table border="0" align="center" class="${tableclass}" id="col1" style="width: 100%">
                <thead>
                    <tr class="sortable">
                        <th colspan="2">
                            <div align="center">
                                	省份管理
                            </div>
                        </th>
                    </tr>
                </thead>
    		<tr>
		        <td style="width: 30%">
		          	<div align="right">区域: <font color="ff0000">*</font></div>
		       	</td>
		        <td>
		           	<input class="${inputclass}" type="text" name="groupby" id="groupby" value="${province.groupby}"   maxlength="10"/>
		        </td>
		</tr>
		<tr>            
		<tr>
		        <td style="width: 30%">
		          	<div align="right">名称: <font color="ff0000">*</font></div>
		       	</td>
		        <td>
		           	<input class="${inputclass}" type="text" name="province" id="province" value="${province.province}"   maxlength="50"/>
		        </td>
		</tr>
		<tr>
		        <td>
		          	<div align="right">邮编: <font color="ff0000">*</font></div>
		       	</td>
		        <td>
		           	<input class="${inputclass}" type="text" name="provinceid" id="provinceid" value="${province.provinceid}"   maxlength="20"/>
		        </td>
		</tr>
                <tr>
                    <td colspan="2">
                        <div align="center">
                            <input class="${btnclass}" type="submit" value="提交" />
                            <input class="${btnclass}" type="reset" value="重置" />
                            <input class="${btnclass}" type="button" value="返回"
                                onclick="window.location='<ls:url address="/admin/system/district/query"/>'" />
                        </div>
                    </td>
                </tr>
            </table>
           </div>
        </form:form>
